// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   discussion_change_ok.java

package intrmanufacture.config.workflow;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class discussion_change_ok extends HttpServlet
{

	public discussion_change_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			ServletContext context = session.getServletContext();
			String path = context.getRealPath("/");
			nseer_db_backup1 intrmanufacture_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 intrmanufacture_db1 = new nseer_db_backup1(dbApplication);
			if (intrmanufacture_db.conn((String)dbSession.getAttribute("unit_db_name")) && intrmanufacture_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String id = request.getParameter("id");
				String type_id = request.getParameter("type_id");
				String cols_number = request.getParameter("cols_number");
				String chain_id_array[] = request.getParameterValues("chain_id");
				if (chain_id_array == null)
				{
					response.sendRedirect((new StringBuilder("intrmanufacture/config/workflow/discussion_change_ok_a.jsp?id=")).append(id).append("&type_id=").append(type_id).toString());
				} else
				{
					String describe1 = "";
					String describe2 = "";
					for (int j = 0; j < chain_id_array.length; j++)
						if (!chain_id_array[j].equals(""))
						{
							for (StringTokenizer token = new StringTokenizer(chain_id_array[j], "/"); token.hasMoreTokens();)
							{
								String human_ID = token.nextToken();
								String human_name = token.nextToken();
								describe1 = (new StringBuilder(String.valueOf(describe1))).append(human_ID).append(", ").toString();
								describe2 = (new StringBuilder(String.valueOf(describe2))).append(human_name).append(", ").toString();
							}

						}

					String sql = "select discussion_id from intrmanufacture_discussion where check_tag='0'";
					for (ResultSet rs = intrmanufacture_db1.executeQuery(sql); rs.next(); intrmanufacture_db.executeUpdate(sql))
						sql = (new StringBuilder("update intrmanufacture_workflow set check_tag='0' where object_ID='")).append(rs.getString("discussion_id")).append("'").toString();

					String sql1 = (new StringBuilder("update intrmanufacture_config_workflow set describe1='")).append(describe1).append("',describe2='").append(describe2).append("' where id='").append(id).append("'").toString();
					intrmanufacture_db.executeUpdate(sql1);
					sql1 = (new StringBuilder("update intrmanufacture_workflow set describe1='")).append(describe1).append("',describe2='").append(describe2).append("' where config_id='").append(id).append("' and check_tag='0'").toString();
					intrmanufacture_db.executeUpdate(sql1);
					response.sendRedirect((new StringBuilder("intrmanufacture/config/workflow/discussion_change_ok_b.jsp?id=")).append(id).append("&type_id=").append(type_id).toString());
				}
				intrmanufacture_db.commit();
				intrmanufacture_db1.commit();
				intrmanufacture_db1.close();
				intrmanufacture_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
